//
//  DateTimePicker.swift
//  HeadlineNews
//
//  Created by han on 2019/7/1.
//  Copyright © 2019 han. All rights reserved.
//

import UIKit

class DateTimePicker: UIView {
    
    static func create(minimumDate: Date? = nil, maximumDate: Date? = nil) -> DateTimePicker {
        
        let dateTimePicker = DateTimePicker()
        dateTimePicker.minimumDate = minimumDate ?? Date(timeIntervalSinceNow: -3600 * 24 * 10)
        dateTimePicker.maximumDate = maximumDate ?? Date(timeIntervalSinceNow: 3600 * 24 * 10)
        assert(dateTimePicker.minimumDate.compare(dateTimePicker.maximumDate) == .orderedAscending, "Minimum date should be earlier than maximum date")
        dateTimePicker.configureView()
        return dateTimePicker
    }
    
   
    var dates: [Date]! = []
    
    private var minimumDate: Date!
    private var maximumDate: Date!
    
    var dayCollectionView: UICollectionView!
    private var contentView: UIView?
    
    private func configureView() {
        
    }
    

}

// subviews
extension DateTimePicker {
    
}

extension DateTimePicker: UICollectionViewDelegate, UICollectionViewDataSource {
    
    func numberOfSections(in collectionView: UICollectionView) -> Int {
        return 1
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return dates.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        return UICollectionViewCell(frame: .zero)
    }
}


extension DateTimePicker: UITableViewDelegate, UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 3
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        return UITableViewCell(frame: .zero)
    }
}
